fastcs_secop

SECoP support using FastCS.

Submodules

version

class fastcs_secop.SecopCommandController(*, connection: IPConnection, module_name: str, command_name: str, datainfo: dict[str, Any], quirks: SecopQuirks)[source]

Bases: Controller

Subcontroller for a SECoP command.

This class is automatically added as a subcontroller by SecopModuleController for command-type parameters.

Parameters:
  • connection – The connection to use.

  • module_name – The module in which this command is defined.

  • command_name – The name of the command.

  • datainfo – The datainfo dictionary for this command.

  • quirks – The quirks configuration (see SecopQuirks).

async execute() None[source]

Execute the command.

async initialise() None[source]

Initialise the command controller.

This will set up PVs for Args and Result (if they have a type).

class fastcs_secop.SecopController(settings: IPConnectionSettings, quirks: SecopQuirks | None = None)[source]

Bases: Controller

FastCS Controller for a SECoP node.

The intended usage is via fastcs.control_system.FastCS:

from fastcs_secop import SecopController, SecopQuirks
from fastcs.control_system import FastCS

controller = SecopController(
    settings=IPConnectionSettings(ip="127.0.0.1", port=1234),
    quirks=SecopQuirks(...),
)

transports = [...]

fastcs = FastCS(
    controller,
    transports,
)
fastcs.run()

See also

Example CA IOC and Example PVA IOC for examples of full configurations

Parameters:
  • settings – The communication settings (e.g. IP address, port) at which the SECoP node is reachable.

  • quirksSecopQuirks that affects how attributes are processed.

async check_idn() None[source]

Verify that the device is a SECoP device.

This is checked using the SECoP identification message.

Raises:

SecopError – if the device is not a SECoP device.

async connect() None[source]

Connect to the SECoP node.

async deactivate() None[source]

Turn off asynchronous SECoP communication.

See activate, deactivate: Control events for details.

async initialise() None[source]

Set up FastCS for this SECoP node.

This introspects the description of the SECoP device to determine the names and contents of the modules in this SECoP node.

A subcontroller of type SecopModuleController is added for each discovered module.

This controller attempts to periodically reconnect to the device if the connection was closed, and disables asynchronous messages on instantiation.

Raises:

SecopError – if the device is not a SECoP device, if a reply in an unexpected format is received, or the SECoP node’s configuration cannot be handled by fastcs_secop.

async ping() None[source]

Ping the SECoP device, to check connection is still open.

Attempts to reconnect if the connection was not open (e.g. closed by remote end or network break).

exception fastcs_secop.SecopError[source]

Bases: Exception

Error raised to identify a SECoP protocol or configuration problem.

class fastcs_secop.SecopModuleController(*, connection: IPConnection, module_name: str, module: dict[str, Any], quirks: SecopQuirks)[source]

Bases: Controller

FastCS controller for a SECoP module.

This class is automatically added as a subcontroller by SecopController for each present SECoP module.

Parameters:
  • connection – The connection to use.

  • module_name – The name of the SECoP module.

  • module – A deserialised description, in the SECoP over-the-wire format, of this module.

  • quirks – Affects how attributes are processed. See SecopQuirks for details.

async initialise() None[source]

Create attributes for all accessibles in this SECoP module.

class fastcs_secop.SecopQuirks(update_period: float = 1.0, skip_modules: Collection[str] = <factory>, skip_accessibles: Collection[tuple[str, str]]=<factory>, raw_accessibles: Collection[tuple[str, str]]=<factory>, raw_array: bool = False, raw_matrix: bool = False, raw_tuple: bool = False, raw_struct: bool = False, max_description_length: int | None = None)[source]

Bases: object

Define special handling for SECoP modules or accessibles.

Not all combinations of SECoP features can be handled by all transports. SecopQuirks allows specifying non-default behaviour to work around these limitations.

max_description_length: int | None = None

Truncate accessible descriptions to this length.

This is useful for transports such as EPICS CA which have a maximum description length.

raw_accessibles: Collection[tuple[str, str]]

Create any listed (module_name, accessible_name) tuples in raw mode.

JSON for the specified accessibles will be treated as strings.

raw_array: bool = False

If the accessible has an array type, read it in raw mode.

JSON values for any array-type accessible will be treated as strings.

raw_matrix: bool = False

If the accessible has a matrix type, read it in raw mode.

JSON values for any matrix-type accessible will be treated as strings.

This is useful for transports which cannot represent arbitrary N-dimensional arrays.

raw_struct: bool = False

If the accessible has a struct type, read it in raw mode.

JSON values for any struct-type accessible will be treated as strings.

This is useful for transports which do not support the FastCS Table type.

raw_tuple: bool = False

If the accessible has a tuple type, read it in raw mode.

JSON values for any tuple-type accessible will be treated as strings.

This is useful for transports which do not support the FastCS Table type.

skip_accessibles: Collection[tuple[str, str]]

Skip creating any listed (module_name, accessible_name) tuples.

skip_modules: Collection[str]

Skip creating any listed modules.

update_period: float = 1.0

Update period, in seconds.